package main

import (
	"fmt"
	_ "github.com/jinzhu/gorm"
	w_tool "wzpsoso.com/w/t1/tools"
)

type platform_alarm struct {
	ID                int    `db:"ID"`
	TABLE_NAME        string `db:"TABLE_NAME"`
	TABLE_CYCLE       string `db:"TABLE_CYCLE"`
	TABLE_LAYER       string `db:"TABLE_LAYER"`
	TABLE_TIME        string `db:"TABLE_TIME"`
	TABLE_ROW_NUMS    int    `db:"TABLE_ROW_NUMS"`
	ALARM_TIPS        string `db:"ALARM_TIPS"`
	ALARM_CEIL_LIMIT  int    `db:"ALARM_CEIL_LIMIT"`
	ALARM_FLOOR_LIMIT int    `db:"ALARM_FLOOR_LIMIT"`
}

const sqlSTD = "select ID,TABLE_NAME,TABLE_CYCLE,TABLE_LAYER,ALARM_TIPS,to_char(TABLE_TIME,'yyyy-MM-dd hh24:mi:ss') from platform_alarm"

func funcTestDemo1() {
	//sql查询标准返回
	sql := "select ID,TABLE_NAME,TABLE_CYCLE,TABLE_LAYER,ALARM_TIPS,to_char(TABLE_TIME,'yyyy-MM-dd hh24:mi:ss') from platform_alarm"
	words := w_tool.SQL_query(w_tool.Lucky_DB, sql)
	for _, raw := range *words {
		//fmt.Println(raw)
		for _, word := range raw {
			fmt.Print(word)
		}
		fmt.Println()
	}
}

func funcTestDemo2() {
	// 需要自己写反射，后期有空再说
	//var s platform_alarm
	sql := "select ID,TABLE_NAME,TABLE_CYCLE,TABLE_LAYER,ALARM_TIPS,to_char(TABLE_TIME,'yyyy-MM-dd hh24:mi:ss') from platform_alarm"
	w_tool.SQL_query_O(w_tool.Lucky_DB, sql)
}

func funcTestDemo3() {
	// sql执行标准返回
	sql := "INSERT INTO LUCKY.platform_alarm(TABLE_NAME,TABLE_CYCLE,TABLE_LAYER,TABLE_TIME,TABLE_ROW_NUMS,ALARM_TIPS,ALARM_CEIL_LIMIT,ALARM_FLOOR_LIMIT) \nVALUES ('X_TABLE','H','O', to_date('20221009','yyyyMMdd'),10000,'XIAOMING|XIAOBAI|HAHA',11000,9000)"
	w_tool.SQL_execute(w_tool.Lucky_DB, sql)
}

func FuncTestJSON() {
	w := w_tool.SQL_query_JSON(w_tool.Lucky_DB, sqlSTD)
	fmt.Println(w)
}

func funcTestQueryObject() {
	w := w_tool.SQL_query_O(w_tool.Lucky_DB, sqlSTD)
	fmt.Println(w)
}

func main() {
	funcTestQueryObject()
}
